/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
 */

/**
 * Created by yfyang on 4/12/14.
 */
define(['adminapp'], function ($app) {
    $app.navactive('users');
    var action_tpl = Handlebars.compile($(g.actiontpl).html());

    $app.listtable({
        'sAjaxSource' : g.ctx + "admin/auth/admin/list",
        'aoColumns'   : [
            $app.checkall,
            $app.autono,
            {'mDataProp': 'id' },
            {'mDataProp': 'name' },
            {'mDataProp': 'real_name' },
            {'mDataProp': 'create_time' },
            {'mDataProp': 'last_login_time' },
            {'mDataProp': 'last_login_ip' },
            {'mDataProp': 'role' }
        ],
        'aoColumnDefs': [
            { 'bSearchable': false, 'bVisible': false, 'aTargets': [ 2 ] },
            {
                'aTargets' : [8],
                'mData'    : null,
                "bSortable": false,
                'mRender'  : function (data, type, full) {
                    var role = full['role'];
                    switch (role) {
                        case 'admin':
                            return '管理员';
                        case 'customer':
                            return '客服人员';
                        case 'merchant-ktv':
                            return 'ktv商户';
                        case 'merchant-repast':
                            return '餐饮商户'
                    }
                    return '';
                }
            },
            {
                'aTargets' : [9],
                'mData'    : null,
                "bSortable": false,
                'mRender'  : function (data, type, full) {
                    return action_tpl(full);
                }
            }
        ]
    }, 'admin-list');
    return {};
});